<template>
	<div>
		<el-button size="mini" 
			@click="addBtn"
			type="primary">添加</el-button>
		<br> <br>
		<el-table  :data="list"
			 border  
			 style="width: 100%"
			>
			<el-table-column   align="center"   prop="id"  label="id"></el-table-column>
			<el-table-column   align="center"   prop="account_title"  label="account_title"></el-table-column>
			<el-table-column   align="center"   prop="account_bank"  label="account_bank"></el-table-column>
			<el-table-column   align="center"   prop="account_type"  label="account_type"></el-table-column>
			<el-table-column   align="center"   prop="status"  label="status"></el-table-column>
			<el-table-column   align="center"   prop="remark"  label="remark"></el-table-column>
			<el-table-column   align="center"   prop="cid"  label="cid"></el-table-column>
			<el-table-column   align="center"   prop="add_time"  label="add_time"></el-table-column>
			<el-table-column   align="center"   prop="update_time"  label="uodate_time"></el-table-column>
			<el-table-column  label="操作"   align="center">
			     <template slot-scope="scope">
			        <span style="margin-right: 10px;" class="button_text" @click="editRow(scope.row)">编辑</span>
			        <span class="button_text" @click="delRow(scope.row.id)">删除</span>
			     </template>
			 </el-table-column>
		</el-table>
		<div class="page">
		    <el-pagination
		            background
		            @size-change="pageChange"
		            @current-change="handleCurrentChange"
		            :current-page="page"
		            :page-size="pageSize"
		            layout="total, sizes, prev, pager, next, jumper"
		            :total="page_totle">
		    </el-pagination>
		</div>
		<el-dialog
		        title="编辑"
				:close-on-click-modal="false"
				:modal-append-to-body="false"
				:append-to-body="true"
		        :visible.sync="formShow"
		        width="1000px"
		>
		  <div>
			  <el-form ref="form" :model="form" label-width="130px">
				  <el-form-item label="id">
				      <el-input v-model="form.id" size="small"></el-input>
				  </el-form-item>
				  <el-form-item label="account_bank">
				      <el-input v-model="form.account_bank" size="small"></el-input>
				  </el-form-item>
				 <el-form-item label="account_title">
				     <el-input v-model="form.account_title" size="small"></el-input>
				 </el-form-item>
				 <el-form-item label="account_type">
				     <el-input v-model="form.account_type" size="small"></el-input>
				 </el-form-item>
				 <el-form-item label="add_time">
				     <el-input v-model="form.add_time" size="small"></el-input>
				 </el-form-item>
				 <el-form-item label="cid">
				     <el-input v-model="form.cid" size="small"></el-input>
				 </el-form-item>
				 <el-form-item label="remark">
				     <el-input v-model="form.remark" size="small"></el-input>
				 </el-form-item>
				 <el-form-item label="status">
				     <el-input v-model="form.status" size="small"></el-input>
				 </el-form-item>
				 <el-form-item label="update_time">
				     <el-input v-model="form.update_time" size="small"></el-input>
				 </el-form-item>
				 
				  <el-form-item >
				      <el-button type="primary" @click="confirm" size="small">确定</el-button>
				  </el-form-item>
			  </el-form>
		  </div>
		</el-dialog>
	</div>
</template>

<script>
	
	export default {
		components:{
			
		},
		data(){
			return {
				formShow:false,
				page:1,
				pageSize:10,
				page_totle:0,
				list:[],
				table_name:"account_info",
				form:{
					id:'',
					account_bank:"",
					account_title:"",
					account_type:'',
					add_time:"",
					cid:"",
					remark:"",
					status:'',
					update_time:''
				}
			}
		},
		mounted() {
			this.lodeList()
		},
		methods:{
			addBtn(){
				this.form = {
					id:'',
					account_bank:"",
					account_title:"",
					account_type:'',
					add_time:"",
					cid:1,
					remark:"",
					status:'',
					update_time:''
				}
				this.formShow = true
			},
			editRow(row){
				this.formShow = true
				for(let i in this.form){
					this.form[i] = row[i]
				}
			},
			confirm(){
				let params = {
					table_name:this.table_name,
					dd:this.form
				}
				this.$post('/buyerSys/updateErpData',params,res=>{
					this.formShow = false
					this.lodeList()
				})
			},
			delRow(id){
				console.log(id)
					this.$confirm('确定删除?', '提示', {
						  confirmButtonText: '确定',
						  cancelButtonText: '取消',
						  type: 'warning'
						}).then(() => {
							let params = {
								dd:{id:id},
								table_name:this.table_name
							}
						 this.$post('/buyerSys/delData',params,res=>{
							 if(res.data.code==200){
								 this.lodeList()
							 }
						 })
				
					})
			},
			lodeList(){
				let params = {
					page:this.page,
					pageSize:this.pageSize,
					table_name:this.table_name,
					// map:[
					// 	[
					// 		'account_title','=','杨茹 中国'
					// 	]
					// ]
				}
				this.$post('/buyerSys/getErpData',params,res=>{
					let data = res.data.data
					this.page_totle = data.count
					this.list = data.result
				})
			},
			
		}
	}
</script>

<style>
</style>